package com.springinaction.springidol;

import org.aspectj.lang.ProceedingJoinPoint;

/**
 * 创建一个观众类
 * 用来做切面
 * Spring的aop只能达到方法
 * @time 2014年11月28日09:31:52
 * @author xupeng
 *
 */
public class Audience {
	
	public void takeSeats() {
		System.out.println("The audience is taking their seats.");
	}

	public void trueOffCellPhones() {
		System.out.println("The audiece is turning off their cellphone");
	}
	
	public void applaud() {
		System.out.println("CLAP CLAP CLAP CLAP CLAP");
	}
	
	public void demandRefund() {
		System.out.println("Boo!We want our money back!");
	}
	
	public void watchPerformance(ProceedingJoinPoint joinPoint) {
		
		try {
		System.out.println("The audience is taking their seats.");
		System.out.println("The audiece is turning off their cellphone");
		
		//表演之前
		long start = System.currentTimeMillis();
		//执行被通知的方法
		joinPoint.proceed();
		//表演之后
		long end = System.currentTimeMillis();
		System.out.println("CLAP CLAP CLAP CLAP CLAP");
		System.out.println("The performance took " + (end - start) + " milliseconds.");
		
		} catch (Throwable e) {
			System.out.println("Boo!We want our money back!");
		}
		
	}

}
